package com.lexiang.sms.listener.sms;


import com.lexiang.sms.utils.SmsUtil;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @BelongsProject:coder_parent
 * @BelongsPackage:com.coder.sms.listener.Sms
 * @Author:linchong
 * @CreateTime:2019-01-07 20:18
 * @Description:
 */
@Component
@RabbitListener(queues = "sms")
public class SmsListener {

    @Autowired
    private SmsUtil smsUtil;

    @Value("${smsbao.sms.accessKeyId}")
    private String accessKeyId;

    @Value("${smsbao.sms.accessKeySecret}")
    private String accessKeySecret;

    @RabbitHandler
    public void executeSms(Map<String,String> map){
        String mobile = map.get("mobile");
        String checkcode = map.get("checkcode");
        System.out.println("手机号："+map.get("mobile"));
        System.out.println("验证码："+map.get("checkcode"));
        smsUtil.sendSms(mobile,accessKeyId,accessKeySecret,checkcode);

    }
}
